﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AiXiu.Model;

namespace AiXiu.Common
{
    public class GetSqlMethod
    {
        /// <summary>
        /// 获取Sql Server数据库的当前时间
        /// </summary>
        /// <returns>数据库的当前时间</returns>
        public static DateTime getMsServerDateTime()
        {
            using (var db = new AiXiuDbContext())
            {
                DateTime? now = db.Database.SqlQuery<DateTime?>("select getdate()").First();
                return now == null ? DateTime.Now : now.Value;

            }
        }
    }
}
